<template>
  <page-meta :root-font-size="$rootFontSize"></page-meta>
  <view style="min-height: 100vh; background: #fbf2f3">
    <u-loading-page
      :loading="isLoading"
      loading-mode="spinner"
      icon-size="56rpx"
      loading-text="拼命加载中..."
      fontSize="28rpx"
      class="z-50 top-0"
    ></u-loading-page>
    <!-- #ifdef APP-PLUS -->
    <view
      class="w-full bg-primary"
      :style="{ height: statusBarHeight * 2 + 'rpx' }"
    ></view>
    <!-- #endif -->
    <view class="pt-3 pb-10 bg-orderList">
      <!--头部-->
      <view class="mx-4 flex items-center py-6">
        <view class="w-1/6" @click="onBack"
          ><u-icon name="arrow-left" color="#ffffff" size="42rpx"></u-icon
        ></view>
        <view class="text-white text-xl w-4/6 text-center">我的订单</view>
        <view class="w-1/6 flex justify-between" @click="isSearch = !isSearch">
          <view></view>
          <u-icon name="search" color="#ffffff" size="48rpx"></u-icon
        ></view>
      </view>
      <view class="mx-3">
        <view class="flex h-9 bg-white rounded-full">
          <view
            class="w-1/4 text-base text-center leading-9"
            @click="typeTab(1)"
            :class="
              searchType == 1 ? 'orderTypeCur rounded-full' : 'text-primary'
            "
            >待操作<text
              class="text-sm ml-1"
              v-if="orderCount.waitOptCount != 0"
              >{{ orderCount.waitOptCount }}</text
            ></view
          >
          <view
            class="w-1/4 text-base text-center leading-9"
            @click="typeTab(2)"
            :class="
              searchType == 2 ? 'orderTypeCur rounded-full' : 'text-primary'
            "
            >待审核<text
              class="text-sm ml-1"
              v-if="orderCount.waitAuditCount != 0"
              >{{ orderCount.waitAuditCount }}</text
            ></view
          >
          <view
            class="w-1/4 text-base text-center leading-9"
            @click="typeTab(3)"
            :class="
              searchType == 3 ? 'orderTypeCur rounded-full' : 'text-primary'
            "
            >售后<text
              class="text-sm ml-1"
              v-if="orderCount.serviceCount != 0"
              >{{ orderCount.serviceCount }}</text
            ></view
          >
          <view
            class="w-1/4 text-base text-center leading-9"
            @click="typeTab(4)"
            :class="
              searchType == 4 ? 'orderTypeCur rounded-full' : 'text-primary'
            "
            >全部</view
          >
        </view>
      </view>
    </view>
    <!--内容-->
    <view
      class="w-full rounded-t-3xl h-4 relative -top-4"
      style="background: #fbf2f3"
    ></view>
    <view class="mx-4 pb-4 relative -top-4" v-if="infiniteList.length > 0">
      <view
        class="bg-white rounded-md mb-4"
        v-for="(item, index) in infiniteList"
        :key="item.id"
      >
        <view class="mx-4">
          <view class="flex justify-between items-center">
            <view class="text-xs leading-8 flex"
              >活动编号 {{ item.activityNo
              }}<u-icon
                name="/static/icons/icon-copy.png"
                size="36rpx"
                class="ml-1"
                @click="copyCode(item.activityNo)"
              ></u-icon
            ></view>
            <view class="text-xs text-primary leading-8 relative"
              >{{ item.topRightTag1 }}
              <text class="absolute top-6 right-0 w-24 text-right"
                >{{ item.topRightTag2 }}
              </text>
            </view>
          </view>
          <view class="flex pb-3">
            <view class=""
              ><u--image
                :src="item.productImg"
                width="160rpx"
                height="160rpx"
                radius="6"
              ></u--image
            ></view>
            <view class="ml-3 w-full">
              <view class="flex justify-between items-center w-full">
                <view class="u-line-1 text-sm w-3/4">{{
                  item.activityName
                }}</view>
                <view class="w-1/4 text-right relative top-5"
                  ><text class="text-sm">￥</text
                  ><text class="text-base font-bold">{{
                    item.deliveryPrice
                  }}</text></view
                >
              </view>
              <view
                class="text-primary text-xs order-btn-border rounded px-2.5 py-1 mt-2"
                style="display: inline-block"
                v-if="item.isSubmit != 1"
              >
                满{{ item.orderPrice }}补贴{{ item.subsidyPrice }}
              </view>
              <view
                class="text-primary text-xs order-btn-border rounded px-2.5 py-1 mt-2"
                style="display: inline-block"
                v-if="item.isSubmit == 1"
              >
                实付{{ item.actualPrice }}返{{ item.subsidyPrice }}
              </view>
            </view>
          </view>
        </view>
        <!--待操作订单列表状态-->
        <view
          class="mx-4 flex justify-between pb-2 items-center"
          v-if="searchType == 1"
        >
          <view class="flex items-center">
            <view v-if="item.seconds > 0 && item.ingStatus != '100'">
              <u-count-down
                :time="item.seconds"
                format="mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
            <view
              class="text-xs ml-1"
              v-if="item.seconds > 0 && item.ingStatus != '100'"
              >后自动取消</view
            >
            <view v-if="item.seconds > 0 && item.ingStatus == '100'">
              <u-count-down
                :time="item.seconds"
                format="HH:mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
          </view>
          <view class="flex" v-if="item.buyerOrderStatus == '1'">
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1 mr-2.5"
              @click="cancelTo(item)"
              >放弃申请</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              @click="confirmTo(item)"
              >进入活动</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '2' && item.ingStatus != '100'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1 mr-2.5"
              @click="cancelTo(item)"
              >取消</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              @click="continueTo(item)"
              >继续</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '3' && item.ingStatus == '100'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-2.5 py-1 mr-2"
              v-if="item.seconds > 0"
              @click="orderService(item)"
              >申请售后</view
            >
            <view
              class="text-xs order-btn-border-black rounded px-2.5 py-1 mr-2"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-2.5 py-1"
              v-if="item.seconds > 0"
              @click="confirmBeforeGoods(item)"
              >确认收货</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              v-else
              @click="confirmGoods(item)"
              >确认收货</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '4' && item.ingStatus == '101'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1 ml-2.5"
              v-if="item.isComment1 == 0"
              @click="shareTo(item, 1)"
              >去评价</view
            >
          </view>
        </view>
        <!--待审核订单列表状态-->
        <view
          class="mx-4 flex justify-between pb-2 items-center"
          v-if="searchType == 2"
        >
          <view class="flex items-center">
            <view v-if="item.seconds > 0">
              <u-count-down
                :time="item.seconds"
                format="HH:mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
            <view class="text-xs ml-1" v-if="item.seconds > 0">待商家审核</view>
          </view>
          <view class="flex">
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
          </view>
        </view>
        <!--待售后订单列表状态-->
        <view
          class="mx-4 flex justify-between pb-2 items-center"
          v-if="searchType == 3"
        >
          <view class="text-xs">客服处理中</view>
          <view class="flex">
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1 ml-2.5"
              v-if="item.ingStatus == 102"
              @click="confirmBeforeGoods(item)"
              >确认收货</view
            >
          </view>
        </view>
        <!--全部订单列表状态-->
        <view
          class="mx-4 flex justify-between pb-2 items-center"
          v-if="searchType == 4"
        >
          <view class="text-xs" v-if="item.buyerOrderStatus == 6"
            >客服处理中</view
          >
          <view class="flex items-center" v-if="item.buyerOrderStatus == 5">
            <view v-if="item.seconds > 0 && item.ingStatus == '6'">
              <u-count-down
                :time="item.seconds"
                format="HH:mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
            <view
              class="text-xs ml-1"
              v-if="item.seconds > 0 && item.ingStatus == '6'"
              >待商家审核</view
            >
          </view>
          <view class="flex items-center">
            <view
              v-if="
                item.seconds > 0 &&
                item.ingStatus != '100' &&
                item.ingStatus != '6' &&
                item.ingStatus != '99'
              "
            >
              <u-count-down
                :time="item.seconds"
                format="mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
            <view
              class="text-xs ml-1"
              v-if="
                item.seconds > 0 &&
                item.ingStatus != '100' &&
                item.ingStatus != '6' &&
                item.ingStatus != '99'
              "
              >后自动取消</view
            >
            <view v-if="item.seconds > 0 && item.ingStatus == '100'">
              <u-count-down
                :time="item.seconds"
                format="HH:mm:ss"
                autoStart
                @finish="refreshList(item)"
              >
              </u-count-down>
            </view>
          </view>
          <view class="flex" v-if="item.buyerOrderStatus == '1'">
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1 mr-2.5"
              @click="cancelTo(item)"
              >放弃申请</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              @click="confirmTo(item)"
              >进入活动</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '2' && item.ingStatus != '100'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1 mr-2.5"
              @click="cancelTo(item)"
              >取消</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              @click="continueTo(item)"
              >继续</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '3' && item.ingStatus == '100'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-2.5 py-1 mr-2"
              v-if="item.seconds > 0"
              @click="orderService(item)"
              >申请售后</view
            >
            <view
              class="text-xs order-btn-border-black rounded px-2.5 py-1 mr-2"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-2.5 py-1"
              v-if="item.seconds > 0"
              @click="confirmBeforeGoods(item)"
              >确认收货</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1"
              v-else
              @click="confirmGoods(item)"
              >确认收货</view
            >
          </view>
          <view
            class="flex"
            v-if="item.buyerOrderStatus == '4' && item.ingStatus == '101'"
          >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1 ml-2.5"
              v-if="item.isComment1 == 0"
              @click="shareTo(item, 1)"
              >去评价</view
            >
          </view>
          <view
            class="flex"
            v-if="
              item.buyerOrderStatus != '4' &&
              (item.ingStatus == '101' || item.ingStatus == '99')
            "
          >
            <view
              class="text-xs order-btn-border-black rounded px-2.5 py-1 mr-2"
              v-if="item.buyerOrderStatus == '9'"
              @click="orderService(item, 3)"
              >申请售后</view
            >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1 ml-2.5"
              v-if="item.isComment1 == 1 && item.isComment2 == 0"
              @click="shareTo(item, 2)"
              >追加评价</view
            >
          </view>
          <view class="flex" v-if="item.buyerOrderStatus == 6">
            <view
              class="text-xs order-btn-border-black rounded px-4 py-1"
              v-if="item.buyerOrderNo != null"
              @click="orderInfo(item)"
              >订单信息</view
            >
            <view
              class="text-xs text-primary order-btn-border rounded px-4 py-1 ml-2.5"
              v-if="item.ingStatus == 102"
              @click="confirmBeforeGoods(item)"
              >确认收货</view
            >
          </view>
        </view>
      </view>
    </view>
    <view class="py-10 w-full" v-else>
      <b-empty></b-empty>
    </view>
    <!--取消原因-->
    <u-popup :show="isShow" @close="isShow = false" :round="25">
      <view class="mx-5 pb-5">
        <view class="text-center text-base leading-10">请选择取消原因</view>
        <u-radio-group
          v-model="cancelReason"
          :borderBottom="true"
          activeColor="#FF3D62"
          placement="column"
          iconPlacement="right"
          iconSize="20px"
        >
          <u-radio
            @change="radioChange"
            :customStyle="{
              paddingTop: '18px',
              paddingBottom: '18px',
            }"
            v-for="(item, index) in radioList"
            :key="index"
            :label="item.name"
            labelSize="14px"
            labelColor="#333333"
            iconColor="#E5E5E5"
            iconSize="20px"
            size="20px"
            :name="item.id"
          >
          </u-radio>
        </u-radio-group>
        <view class="mt-2.5" v-if="isReason">
          <u--input
            v-model="cancelReasonTxt"
            fontSize="28rpx"
            color="#333333"
            placeholderStyle="color: #999999"
            placeholder="其他原因，请输入..."
            clearable
          >
          </u--input>
        </view>
        <view
          class="w-full rounded-full leading-10 text-base h-10 text-center text-white bg-primary bg-box-shadow mt-5"
          @click="cancelConfirm()"
          >确定取消</view
        >
      </view>
    </u-popup>
    <!--订单信息-->
    <u-popup
      :show="orderInfoShow"
      @close="orderInfoShow = false"
      mode="center"
      round="15"
      bgColor="#FFFFFF"
    >
      <view class="w-72">
        <view class="rounded-b-md">
          <view class="mx-4 pt-5">
            <view class="flex items-center text-sm leading-8"
              >店铺名称：<u-icon
                name="/static/icons/icon-taobao.png"
                size="32rpx"
                class="mr-1.5"
                v-if="orderInfoCur.storeType == '40'"
              ></u-icon
              ><u-icon
                name="/static/icons/icon-douyin.png"
                size="32rpx"
                class="mr-1.5"
                v-if="orderInfoCur.storeType == '41'"
              ></u-icon
              >{{ orderInfoCur.storeName }}</view
            >
            <view class="flex items-center text-sm leading-8"
              >订单编号：{{ orderInfoCur.buyerOrderNo
              }}<u-icon
                name="/static/icons/icon-copy.png"
                size="36rpx"
                class="ml-1"
                @click="copyCode(orderInfoCur.buyerOrderNo)"
              ></u-icon
            ></view>
            <view class="mx-14 py-5"
              ><view
                class="w-full rounded-full leading-10 text-base h-10 text-center text-white bg-pink"
                @click="orderInfoShow = false"
                >关闭</view
              ></view
            >
          </view>
        </view>
      </view>
    </u-popup>
    <!--确认收货-->
    <u-modal
      :show="orderGoodsBeforeShow"
      @confirm="orderGoodsTo()"
      ref="uModal"
      title="温馨提示"
      confirmColor="#FF2B2B"
      confirmText="确认收货"
      :showCancelButton="false"
      :closeOnClickOverlay="true"
      @close="orderGoodsBeforeShow = false"
    >
      <view class="w-full">
        <view class="text-sm leading-10 text-center">确认收到货了吗？</view>
        <view class="text-xs text-light text-center"
          >为保障消费者权益，请检查后再确认收货。</view
        >
      </view>
    </u-modal>
    <!--确认收货/申请售后-->
    <u-modal
      :show="orderGoodsShow"
      @cancel="orderService('', 2)"
      @confirm="orderGoodsTo()"
      ref="uModal"
      title="温馨提示"
      confirmColor="#FF2B2B"
      confirmText="确认收货"
      cancelText="申请售后"
      :showCancelButton="true"
      :closeOnClickOverlay="true"
      @close="orderGoodsShow = false"
    >
      <view class="w-full">
        <view class="text-sm leading-10 text-center">确认收到货了吗？</view>
        <view class="text-xs text-light text-center"
          >为保障消费者权益，请检查后再确认收货。</view
        >
      </view>
    </u-modal>
    <!--申请售后-->
    <u-modal
      :show="orderGoodsApplyShow"
      @confirm="orderServiceTo(2)"
      ref="uModal"
      title="温馨提示"
      confirmColor="#FF2B2B"
      confirmText="确认"
      :showCancelButton="false"
      :closeOnClickOverlay="true"
      @close="orderGoodsApplyShow = false"
    >
      <view class="w-full">
        <view class="text-sm leading-10 text-center">确认需要申请售后吗？</view>
      </view>
    </u-modal>
    <!--搜索-->
    <view
      class="bg-white fixed left-0 top-0 w-full h-full z-50"
      v-if="isSearch"
    >
      <view class="mx-3 flex items-center mt-2.5">
        <view @click="isSearch = false"
          ><u-icon name="arrow-left" size="42rpx"></u-icon
        ></view>
        <view class="w-5/6 ml-2.5">
          <u-search
            placeholder="活动编号/订单号"
            v-model="searchKey"
            height="60rpx"
            searchIconSize="40"
            :showAction="false"
          ></u-search
        ></view>
        <view class="text-sm w-1/6 text-center" @click="searchTo">搜索</view>
      </view>
    </view>
  </view>
</template>

<script>
import infinite from '@/mixins/infinite';
import {
  cancelOrder,
  orderList,
  applyConfirm,
  continueOpt,
  getOrderCount,
  continueOptShare,
} from '../../services/mine';

export default {
  mixins: [infinite],
  data() {
    return {
      statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
      isLoading: true,
      isShow: false,
      isReason: false,
      idCur: '',
      radioList: [
        {
          id: 1,
          name: '找不到',
          disabled: false,
        },
        {
          id: 2,
          name: '价格不对',
          disabled: false,
        },
        {
          id: 3,
          name: '验证一直失败',
          disabled: false,
        },
        {
          id: 4,
          name: '其他',
          disabled: false,
        },
      ],
      //查询类型：1-待操作，2-待审核，3-已完成，4-已取消
      searchType: 1,
      //我的订单列表
      infiniteList: [],
      cancelReason: 1,
      cancelReasonTxt: '',
      orderInfoShow: false,
      orderInfoCur: {},
      orderGoodsId: '',
      orderGoodsShow: false,
      orderGoodsApplyShow: false,
      orderGoodsBeforeShow: false,
      //订单数量
      orderCount: {
        serviceCount: 0,
        waitAuditCount: 0,
        waitOptCount: 0,
      },
      //搜索关键字:活动编号、订单号
      searchKey: '',
      isSearch: false,
      curType: '',
    };
  },
  async onShow() {
    const { searchType } = this.$Route.query;
    this.searchType = searchType;
    this.getInfiniteList(true);
  },
  methods: {
    //搜索
    searchTo() {
      try {
        if (this.searchKey == '') {
          uni.showToast({
            title: '请输入活动编号、订单号',
            icon: 'none',
          });
          return;
        }
        //搜索全部订单
        this.searchType = 4;
        this.getInfiniteList(true);
        //回调成功后清空关键字并关闭遮罩
        this.searchKey = '';
        this.isSearch = false;
      } catch (error) {
        console.error(error);
      }
    },
    //我的订单-订单数量
    async _getOrderCount() {
      const { code, data } = await getOrderCount();
      if (code != 200) return;
      this.orderCount = data;
    },
    //申请售后
    async orderServiceTo(optType) {
      let params = {
        buyerPlatformId: process.env.VUE_APP_PLATFORMID,
        id: this.orderGoodsId,
        optType: this.curType,
      };
      const { code, data } = await continueOptShare(params);
      if (code != 200) return;
      //回调成功关闭遮罩弹窗并刷新当前状态订单列表数据
      this.orderGoodsApplyShow = false;
      this.orderGoodsBeforeShow = false;
      this.getInfiniteList(true);
    },
    //申请售后弹窗
    orderService(item, type) {
      if (item) {
        this.orderGoodsId = item.id;
      }
      this.curType = type;
      this.orderGoodsApplyShow = true;
      this.orderGoodsShow = false;
    },
    //确认收货
    async orderGoodsTo() {
      let params = {
        buyerPlatformId: process.env.VUE_APP_PLATFORMID,
        id: this.orderGoodsId,
        optType: 1,
      };
      const { code, data } = await continueOptShare(params);
      if (code != 200) return;
      //回调成功关闭遮罩弹窗并刷新当前状态订单列表数据
      this.orderGoodsShow = false;
      this.orderGoodsBeforeShow = false;
      this.getInfiniteList(true);
    },
    //确认收货（72小时内）弹窗
    confirmBeforeGoods(item) {
      this.orderGoodsId = item.id;
      this.orderGoodsBeforeShow = true;
    },
    //确认收货弹窗
    confirmGoods(item) {
      this.orderGoodsId = item.id;
      this.orderGoodsShow = true;
    },
    //订单信息弹窗
    orderInfo(item) {
      this.orderInfoShow = true;
      this.orderInfoCur = item;
    },
    //复制活动编号
    copyCode(content) {
      uni.setClipboardData({
        data: content,
        success: function () {
          //console.log('复制成功');
        },
      });
    },
    //取消原因选择
    radioChange(name) {
      if (name == 4) {
        this.isReason = true;
      } else {
        this.isReason = false;
      }
    },
    //去评价&追加评价
    async shareTo(item, commentType) {
      this.$Router.push({
        name: 'evaluate-order',
        params: {
          id: item.activityNo,
          commentType: commentType,
        },
      });
    },
    //待操作状态继续
    async continueTo(item) {
      this.$Router.push({
        name: 'order-submit',
        params: {
          id: item.id,
        },
      });
    },
    //待操作状态确认
    async confirmTo(item) {
      const { code, data } = await applyConfirm({ id: item.id });
      if (code != 200) return;
      uni.$u.toast('操作成功');
      //this.getInfiniteList(true);
      this.$Router.push({
        name: 'order-submit',
        params: {
          id: item.id,
        },
      });
    },
    //倒计时结束刷新列表
    refreshList(item) {
      item.seconds = undefined;
      setTimeout(() => {
        this.getInfiniteList(true);
      }, 1500);
    },
    //容器Tab
    typeTab(type) {
      this.searchType = type;
      this.getInfiniteList(true);
    },
    //返回上一页 => 改成返回我的页面
    onBack() {
      //uni.navigateBack();
      uni.switchTab({
        url: '/pages/mine/mine',
      });
    },
    //获取订单列表
    async getInfiniteData(pageIndex, pageSize) {
      //每次刷新活动订单列表时同时需要刷新订单数量接口
      this._getOrderCount();
      let params = {
        pageNum: pageIndex,
        pageSize: pageSize,
        searchType: this.searchType,
        searchKey: this.searchKey,
      };
      const { code, data } = await orderList(params);
      if (code != 200) return;
      this.isLoading = false;
      data.records.map((item) => {
        if (item.expireTime != null) {
          //ios系统上的浏览器new date()问题处理
          item.seconds = parseInt(
            new Date(item.expireTime.replace(/-/g, '/')) -
              new Date(item.serverTime.replace(/-/g, '/'))
          );
          //console.log(item.seconds);
        }
      });
      return data.records;
    },
    //取消订单
    cancelTo(item) {
      this.idCur = item.id;
      this.isShow = true;
    },
    //确认取消订单
    async cancelConfirm() {
      if (this.cancelReason == 4) {
        if (this.cancelReasonTxt == '') {
          uni.showToast({
            title: '其他原因，请输入...',
            icon: 'none',
          });
          return;
        }
      }
      const { code, data } = await cancelOrder({
        id: this.idCur,
        cancelReason: this.cancelReason,
        cancelReasonTxt: this.cancelReason == 4 ? this.cancelReasonTxt : '',
      });
      if (code != 200) return;
      this.isShow = false;
      uni.$u.toast('操作成功');
      this.getInfiniteList(true);
    },
  },
};
</script>

<style>
page {
  background: #fbf2f3;
}
</style>
